package com.lwb.ztx.news.presenter;

import com.lwb.ztx.bean.NewsAndBannerBean;
import com.lwb.ztx.bean.NewsBean;
import com.lwb.ztx.news.model.NewsListModel;
import com.lwb.ztx.news.model.NewsListModelImpl;
import com.lwb.ztx.news.view.NewsListView;

import java.util.List;

/**
 * Created by luweibin on 2016/5/27.
 */
public class NewsListPresenterImpl implements NewsListPresenter,NewsListModelImpl.OnLoadListener {
    private NewsListModel model;
    private NewsListView newsListView;

    public NewsListPresenterImpl(NewsListView newsListView) {
        this.model = new NewsListModelImpl(this);
        this.newsListView = newsListView;
    }

    @Override
    public void getNews(String url, int page) {
        model.loadNews(url,page);
    }

    @Override
    public void onSuccess(NewsAndBannerBean beans, int page) {
        if(page == 1) {
            newsListView.addNews(beans);
        } else {
            newsListView.addMoreNews(beans);
        }
    }

    @Override
    public void onFailure() {

    }
}
